class Solution
{
public:
    int areaOfMaxDiagonal(vector<vector<int>> &dimensions)
    {
        int maxDiag = 0;
        int maxArea = 0;
        for (auto &d : dimensions)
        {
            int diag = d[0] * d[0] + d[1] * d[1];
            if (diag == maxDiag)
            {
                maxArea = max(maxArea, d[0] * d[1]);
            }
            else if (diag > maxDiag)
            {
                maxArea = d[0] * d[1];
                maxDiag = diag;
            }
        }
        return maxArea;
    }
};